let vm = new Vue({
    el: "#articleMain",
    data: {
        userLoginInfo: {},
        params: {
            value: '',
        },
        pageInfo:{
            pageNum:1,
            pageSize:3,
        },
        flag: '',
    },
    methods: {
        logout: function () {
            axios({
                url: `user/logout`,
            }).then(res => {
                sessionStorage.clear();
                location.href = "logout";
            })
        },
        /**
         * 文章条件分页
         * @param pageNum
         * @param pageSize
         */
        findArticleByCondition:function (pageNum,pageSize) {
            axios({
                url:`article/findArticleByCondition/${pageNum}/${pageSize}`,
                method: 'post',
                data: this.params
            }).then(res=>{
                this.pageInfo=res.data.data;

            })
        },
        /**
         * 点击了发布 文章按钮
         * @param myId 登录id
         */
        publishArticle:function (myId) {
            layer.myId=myId;
            console.log(this.userLoginInfo.data);
            layer.myName=this.userLoginInfo.data.realName;

            let index=layer.open({
                type:2,
                title:false,
                content:['getArticleAdd'],
                area:['70%','85%'],
                end:()=>{
                    this.findArticleByCondition(1,this.pageInfo.pageSize)
                }
            });

        }
    },
    created: function () {
        this.flag = 3;
        let userInfo = sessionStorage.getItem("vmUserInfo");
        if (userInfo != null) {
            this.userLoginInfo = JSON.parse(userInfo);
        } else {
            location.href = "";
        }
        this.findArticleByCondition(this.pageInfo.pageNum,this.pageInfo.pageSize)
    },
    mounted() {
        // window事件对象调用this.xxx
        // window.onClickKeyCode=this.xxx
    },
});